/*  Copyright (C) 2008  Alexander Blyzniuchenko (BlezAlex)

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

using System.Collections.Generic;

namespace DC.Http
{
    class ResponseElement
    {
        private readonly string _name;

        public string Name
        {
            get { return _name; }
        }

        private ResponseElement(string name)
        {
            _name = name;
            Properties.Add(Property.Get("displayname", "DAV:"), _name);
            Properties.Add(Property.Get("creationdate", "DAV:"), "2008-05-31T16:21:18.781Z");
            Properties.Add(Property.Get("getlastmodified", "DAV:"), "Sat, 31 May 2008 16:51:00 GMT");

            Properties.Add(Property.Get("ishidden", "DAV:"), "0");
            Properties.Add(Property.Get("getcontenttype", "DAV:"), "");
        }

        public ResponseElement(DcDirectory dir)
            : this(dir.Name)
        {
            Properties.Add(Property.Get("iscollection", "DAV:"), "1");
        }

        public ResponseElement(DcFile file)
            : this(file.Name)
        {
            Properties.Add(Property.Get("iscollection", "DAV:"), "0");
            Properties.Add(Property.Get("resourcetype", "DAV:"), "");
            Properties.Add(Property.Get("getcontentlength", "DAV:"), file.Size.ToString());
        }

        public Dictionary<Property, string> Properties = new Dictionary<Property, string>();
    }
}